const mongoose = require("./db");
const { getId } = require("../utils/getMethods");

const userSchema = new mongoose.Schema(
  {
    id: {
      type: Number,
      unique: true,
      default: () => getId,
    },
    openId: {
      type: String,
    },
    userType: {
      type: String,
    },
    photoUrl: {
      type: String,
      default: "/upload/user-girls.png",
    },
    nickName: {
      type: String,
    },
    Account: {
      type: String,
    },
    username: {
      type: Number,
    },
    password: {
      type: String,
    },
    sex: {
      type: Number,
      default: 0,
    },
    currentLeader: {
      type: mongoose.Types.ObjectId,
      ref: "leaderAddress",
    },
  },
  { versionKey: false }
);

const userModel = mongoose.model("user", userSchema, "user");

module.exports = { userModel };
